var fs=require("fs");

/*fs.open("./1.txt","r+",function (err,fd) {
    if(err){
        throw err;
    }else{
        console.log(fd);
        var buf=Buffer.alloc(26);
        fs.read(fd,buf,0,20,0,function (err, bytesRead, buffer) {
            console.log(buffer);
        });

    }
});*/

/*var fd=fs.openSync("./1.txt","r+");
console.log(fd);
var buf=Buffer.alloc(26);
var buf1=fs.readSync(fd,buf,0,20,0);

console.log(buf1);*/


fs.open("./1.txt","r+",function (err,fd) {
    if(err){
        throw err;
    }else{
        console.log(fd);

        fs.write(fd,"你好！",0,function (err,written,str) {
            console.log(err);
            console.log(written);
            console.log(str)
        })
    }
});